package com.partsoft.spring.webapp.zks;

import com.partsoft.spring.log.Log;

import javax.servlet.ServletRequestEvent;
import javax.servlet.ServletRequestListener;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

/**
 * 粘合ZK与Spring的Session监听器
 * 
 * @author neeker
 */
public class SessionListener extends com.partsoft.spring.webapp.SessionListener implements HttpSessionListener,
		ServletRequestListener {

	private org.zkoss.zk.ui.http.HttpSessionListener zkSessionListener = new org.zkoss.zk.ui.http.HttpSessionListener();

	public void sessionCreated(HttpSessionEvent se) {
		super.sessionCreated(se);
		try {
			zkSessionListener.sessionCreated(se);
		} catch (Exception ze) {
			Log.error("Occur an error when ZK session creating:", ze);
		}
	}

	public void sessionDestroyed(HttpSessionEvent se) {
		super.sessionDestroyed(se);
		try {
			zkSessionListener.sessionDestroyed(se);
		} catch (Exception ze) {
			Log.error("Occur an error when ZK session destroying:" + ze);
		}
	}

	public void requestDestroyed(ServletRequestEvent sre) {
		super.requestDestroyed(sre);
	}

	public void requestInitialized(ServletRequestEvent sre) {
		super.requestDestroyed(sre);
	}

}
